<template>
    <section id="" class="detail">
        详情页面
         <section class="video_txt">
                <div class="video_txt_wrap">
                    <p>
                        <template v-if="lists.timelong > 90 ">
                        {{ lists.timelong }}分钟
                        </template>
                        <template v-else>
                        {{ lists.timelong }}季
                        </template>
                        {{ lists.type }}
                    </p>
                    <p>{{ lists.time1 }}( {{lists.country}} )上映 {{lists.country}}</p>
                    <p>{{ lists.actors }}</p>
                </div>
            </section>
            <section class="video_about"> 
                <h3>{{ lists.name }}的剧情简介</h3>
                <p>
                    {{ lists.detail }}
                </p>
            </section>
          <section class="video_comments">
                <h3>评论({{pageNeedComments.length}})</h3>
                <ul id="ul">
                    <li :key="comment.id" v-for="comment in comments">

                        <div class="comments_detail">
                            <h4> {{comment.userName}}</h4>
                            <p> {{comment.date}}</p>
                            <div>{{comment.content}}</div>
                        </div>
                    </li>
                </ul>
            </section>
            <section>
            	<button @click="start"  v-if="index!=1">首页</button>
            	<button @click="prev"  v-if="index!=1">上一页</button>
            	<button @click="next" v-if="index!=sumpage">下一页</button>
            	<button @click="end" v-if="index!=sumpage">尾页</button>
            	<p>{{index}}/{{sumpage}}</p>
            	<p>111</p>	
            </section>
    </section>
</template>

<script>
import {getDetail,getCommont,baseUrl} from "@/config/axios.js"
export default {
    name: 'detail',
    data () {
        return {
          id:"",
          pageNeedComments:[],
          comments:[],
           url:"",
           lists:{},
           index:1,
           sumpage:0
        }
    },
 
    created () {
    	this.url=baseUrl;
    	
    	
    	console.log(this.$route.params.id)
    	var id=this.$route.params.id;
    	var data={videoId:id}
    	
    	getDetail(data).then(res=>{
    		console.log(res.data)
    		this.lists=res.data.data[0][0]
    		console.log(this.lists)
    	})
    	//获取评论
    	getCommont(data).then(res=>{
    		console.log(res.data)
    		this.pageNeedComments=res.data.data;
    		this.comments=res.data.data.slice(0,5);
    		this.sumpage=Math.ceil(this.pageNeedComments.length/5);
    	})

    },
    methods:{
   		next(){
   			this.index++;
   			
   			if(this.index>=this.sumpage){
   				this.index=this.sumpage
   			}
   			//1 0-5  2 5-10  3 10-15  
			this.comments=this.pageNeedComments.slice(5*(this.index-1),5*(this.index))
   		},
   		prev(){
   			this.index--;
   			if(this.index<=1){
   				this.index=1
   			}
   			//1 0-5  2 5-10  3 10-15  
			this.comments=this.pageNeedComments.slice(5*(this.index-1),5*(this.index))
   		},
   		start(){
   			this.index=1;
   			this.comments=this.pageNeedComments.slice(0,5)
   		},
   		end(){
   			this.index=this.sumpage,
   			this.comments=this.pageNeedComments.slice(5*(this.index-1))
   			
   		}
   		
    }
}

</script>

<style scoped lang="scss">
.detail{
	padding-bottom: 1rem;
	min-height: 100%;
	overflow-y: auto;
	overflow-x: hidden
}
header{
	height: 3.0rem;
	position: relative;
	display: flex;
	background: #4ebf60;
	.wrap{
		display: flex;
		color: #fff;
		img{
			width: 1.7rem;
			height: 2.4rem;
			margin-left: 0.4rem;
			position: relative;
			bottom: -1rem;
		}
		.video_name{
			margin:1.4rem 0.5rem;
			h3{
				font-size: 24px;
				white-space: nowrap;
				width: 4.5rem;
				overflow: hidden;
				text-overflow: ellipsis;
			}
			.score_wrap{
				display: flex;
				strong{
					font-size: 28px;
					color: #fff;
					margin-right: 0.2rem;
					font-weight: normal;
				}
				.score{
					font-size: 14px;
					color: #f2f2f2;
				}
			}
		}
		.back{
				position: absolute;
				top: 0.2rem;
				left: 0.3rem;
				font-size: 13px;
				i{
					font-size: 15px	;
				}
				border:1px solid #fff;
				padding:0.06rem 0.14rem;
				border-radius:4px;
				&:active{
			        background: rgba(0,0,0,0.1)
			    }
			}
	}
	& > a{
		position: absolute;
		right: 0.2rem;
		top: 0.2rem;
	}
}
.video_txt{
	margin-top: 0.8rem;
	font-size: 16px;
	.video_txt_wrap{
		margin:0 0.4rem;
		color: #111;
		p:nth-child(2){
			margin:0.05rem 0;
		}
	}
}
.video_about{
	padding: 0 0.4rem 0.8rem;
	h3{
		margin: 0.5rem 0 0.3rem 0;
		color: #afafaf;
		font-size: 15px;
	}
	p{
		font-size: 14px;
		text-indent: 2em;
		word-wrap:break-word;
		word-break:break-all;
	}
}
.video_comments{
	margin-left: 0.4rem;
	h3{
		font-size: 16px;
		margin-bottom: 0.2rem;
	    color: #afafaf;
	}
	ul{
		
		li{
			&+li{
				margin-top: 0.3rem;
			}
			display: flex;
			.avator{
				width: 0.6rem;
				height: 0.6rem;
				margin: 0.05rem 0.2rem 0 0 ;
				border-radius:50%;
				background: #4ebf60;
				text-align: center;
				line-height: 0.6rem;
				color: #fff;
				font-size: 16px;
				overflow: hidden;
				flex: none;
				img{
					width: 100%;
					height: 100%;
				}
			}
			.comments_detail{
				font-size: 16px;
				width: 95%;
			    margin-right: 0.5rem;
				p{
					font-size: 14px;
					color: #afafaf;
				}
				h4{
					width: 70%;
					white-space: nowrap;
					text-overflow: ellipsis;
					overflow: hidden;
				}
			}
		}
	}
}
.like_list{
	width: 80%;
	margin:0.5rem auto;
	display: flex;
	justify-content: space-between;
	position: relative;
	.like{
		width: 50%;
		text-align: center;
		border:1px solid #4ebf60;
		margin:0 0.3rem;
		border-radius:8px;
		padding:0.10rem 0;
		color: #4ebf60;
		font-size: 14px;
		&:active{
			background: #4ebf60;
			color: #fff;
		}
	}
	.like.like_active{
		background: #4ebf60;
		color: #fff;

	}
	.like.likeDisable{
		background: #f5f5f5;
		color: #4ebf60;
		&:active{
			background: #f5f5f5;
			color: #4ebf60;
		}
	}
	p{
		position: absolute;
		bottom: -0.4rem;
		left: 50%;
		transform: translateX(-50%);
		color: #ec5051;
	}
}
.fixed_comment{
	position: fixed;
	bottom: 0;
	left: 0;
	width: 100%;
	
	display: flex;
	justify-content: space-between;
	padding: 0 0.1rem 0.05rem 0.1rem;
	background: #fff;
	input{
		border-radius:5px;
		border:none;
		border:1px solid #4ebf60;
		padding:0 0 0 0.2rem;
		width: 100%;
		height: .75rem;
	}
	button{
		border:none;
		width: 1.5rem;
		padding:0.15rem 0.25rem;
		border-radius:5px;
		margin-left: 0.1rem;
		background: #63bb71;
		color: #fff;
		font-size: 14px;
	}
	button.disabled{
		background: #ccc;
	}
}
.page {
  margin: 0.2rem 0;
  display: flex;
  justify-content: center;
  align-items: center;
   div {
	display: inline;
	background: #4ebf60;
	color: #fff;
	text-align: center;
	margin: 0 0.05rem;
	border-radius: 5px;
	padding: 0.08rem 0.14rem;
	&.pageNum{
		background: #ccc;
	}
  }
  div:active {
	background: #89e498;
  }
}
.page-scale-enter-active,
.page-scale-leave-active {
  transition: all 0.6s;
}

.page-scale-enter,
.page-scale-leave-active {
  transform: scale(0)
}




</style>
